/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */
package com.example.generator.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 数据源表
 */
@Getter
@Setter
@TableName("gen_datasource")
public class GenDatasource implements Serializable {

	@Serial
	private static final long serialVersionUID = 1L;

	/**
	 * 数据源记录主键
	 */
	@TableId(type = IdType.ASSIGN_ID)
	private Long id;

	/**
	 * 数据源记录名称
	 */
	private String name;

	/**
	 * 数据库类型
	 */
	private DsType dsType;

	/**
	 * 配置类型 （0 主机形式 | 1 url形式）
	 */
	private Integer confType;

	/**
	 * 主机地址
	 */
	private String host;

	/**
	 * 端口
	 */
	private Integer port;

	/**
	 * 数据库名称
	 */
	private String dsName;

	/**
	 * jdbc-url
	 */
	private String url;

	/**
	 * 数据库用户名
	 */
	private String username;

	/**
	 * 数据库密码
	 */
	private String password;

	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	private LocalDateTime createTime;

	/**
	 * 修改时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	private LocalDateTime updateTime;

	/**
	 * 0-正常，1-删除
	 */
	@TableLogic
	@TableField(fill = FieldFill.INSERT)
	private String delFlag;

	public enum DsType {
		/**
		 * mysql
		 */
		MYSQL,
		/**
		 * oracle
		 */
		ORACLE,
		/**
		 * sqlserver
		 */
		SQLSERVER,
		/**
		 * postgresql
		 */
		POSTGRESQL
	}
}
